/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bff.slimserver.musicjukebox.lib.actions;

import com.bff.slimserver.music.exceptions.PlaylistException;
import com.bff.slimserver.musicjukebox.lib.JukeboxProperties;
import com.bff.slimserver.musicjukebox.lib.events.PlayerChosenEvent;
import com.bff.slimserver.musicjukebox.lib.events.PlayerChosenListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import org.bff.slimserver.SlimPlaylist;

/**
 *
 * @author bill
 */
public abstract class PlaylistAction extends AbstractAction implements PlayerChosenListener {

    private SlimPlaylist playlist;

    public PlaylistAction(SlimPlaylist playlist) {
        this.playlist = playlist;
        JukeboxProperties.getInstance().addPlayerChosenListener(this);
    }


    @Override
    public void playerChosen(PlayerChosenEvent event) {
        try {
            this.playlist = JukeboxProperties.getInstance().getPlaylist();
        } catch (PlaylistException ex) {
            Logger.getLogger(PlaylistAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    /**
     * @return the playlist
     */
    protected SlimPlaylist getPlaylist() {
        return playlist;
    }
}
